package com.dev.mainual.throwable.ssm;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * ClassName: XXService
 * Description:
 * Date: 2019/1/28 12:44 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Service
public class XXService {

    @Autowired
    private XXDao xxDao;


    @Transactional(rollbackFor = Exception.class)
    public boolean add(String user) throws UserIsExistException {
        if (xxDao.selectOne(user)) {
            throw new UserIsExistException("账号已经存在");
        }

        return xxDao.insert(user) > 0;
    }
}
